/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.hpi.generator.helpers;

import de.hpi.generator.generator.distributors.DataDistributor;
import de.hpi.generator.model.Column;
import de.hpi.generator.model.Table;

/**
 *
 * @author igor_c
 */
public class TableDiagnostic {

    public static void showTableInfo(Table aTable) throws Exception {
        int aNumberOfRowsInTable = getNumberOfRowsInTable(aTable);
        System.out.println(String.format("Table name: %s", aTable.getName()));
        System.out.println(String.format("Min rows: %d", aTable.getMinRowNumbers()));
        System.out.println(String.format("Columns: "));

        for (Column aColumn : aTable.getColumns()) {

            System.out.println(String.format("Columns name: %s", aColumn.toString()));
            DataDistributor aDataDistributor = aColumn.getDataDistributor();
            System.out.println(String.format("Distributor type: %s parameters: %s", aDataDistributor.getName(), aDataDistributor.getaDistributionModel().params));

            int aColumnAcrualRows = aColumn.getNumberOfValues();
            System.out.println(String.format("Actual rows: %d", aColumnAcrualRows));
            System.out.println(String.format("Is balanced: %s", (aNumberOfRowsInTable == aColumnAcrualRows) ? "YES" : "NO"));
            System.out.println();
        }
        System.out.println();
        System.out.println();
    }

    private static int getNumberOfRowsInTable(Table aTable) {
        int aNumberOfValues = aTable.getColumns().get(0).getNumberOfValues();
        return aNumberOfValues;
    }
}
